<?php
/**
 * 显示某标签的相关内容
 *
 */
define('SCR','tag');
require_once('global.php');
require_once(R_P.'require/init.php');

$tagName = urldecode($_SERVER['QUERY_STRING']);
unset($_POST,$_GET,$_REQUEST);
if(!$tagName)
{
	throwError('data_error');
}
$tagName = addslashes($tagName);
require_once(R_P.'require/class_cate.php');
$cate = new Cate();

$rs = $db->get_one("SELECT * FROM cms_tags WHERE tagname='$tagName'");
if(!$rs)
{
	throwError('data_error');
}
if($rs['num']>0)
{
	$tagId = intval($rs['tagid']);
	unset($rs);
	$tagNum = $very['tagsnum'] ? intval($very['tagsnum']) : 50; //默认显示50篇最新文章
	$rs = $db->query("SELECT i.title,i.url,i.tid,i.cid,i.postdate FROM cms_contenttag t LEFT JOIN cms_contentindex i USING(tid) WHERE t.tagid='$tagId' LIMIT $tagNum");
	$tagInfo = array();
	while ($tag = $db->fetch_array($rs)) {
		if($tag['url']){
			$tag['url'] = $very['htmdir'].'/'.$tag['url'];
		}else{
			$tag['url'] = "view.php?tid=".$tag['tid']."&cid=".$tag['cid'];
		}
		$tag['cname'] = $catedb[$tag['cid']]['cname'];
		$tagInfo[] = $tag;
	}
}

start();
require Template();
footer();
?>